package com.example.areaofthesquare;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;

import java.util.ArrayList;
import java.util.List;

public class ResultActivity extends AppCompatActivity {

    private List<Point> mAllPointList;
    private List<Point> mSqualeList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_result);
        CustomView customView = findViewById(R.id.custom);
        Intent intent = getIntent();
        //从intent获取List

        List<Point> allPointList = new ArrayList<>();
        allPointList = (List<Point>) intent.getSerializableExtra("pointList");
//        allPointList.add(new Point(0,1));
//        allPointList.add(new Point(2,3));
//        allPointList.add(new Point(3,4));
//        allPointList.add(new Point(-1,-2));
//        allPointList.add(new Point(1,-2));
//        allPointList.add(new Point(-1,-2));
//        allPointList.add(new Point(4,2));
//        allPointList.add(new Point(3,-2));
//        allPointList.add(new Point(6,-7));
//        allPointList.add(new Point(-9,-2));
//        allPointList.add(new Point(-6,3));
//        allPointList.add(new Point(-6,-5));
//        allPointList.add(new Point(-3,1));
//        allPointList.add(new Point(3,3));
//        allPointList.add(new Point(4,1));
//        allPointList.add(new Point(5,1));
//        allPointList.add(new Point(6,1));
//        allPointList.add(new Point(7,1));
//        allPointList.add(new Point(11,0));
//        allPointList.add(new Point(0,5));
//        allPointList.add(new Point(1,0));
//        allPointList.add(new Point(0,1));
//        allPointList.add(new Point(1,3));
//        allPointList.add(new Point(4,1));
        customView.setmAllPointList(allPointList);

        Utils utl = new Utils();
        //设置初始点
        utl.setmPointList(allPointList);
        //计算旋转后的点
        allPointList = utl.countSpinPointList(allPointList);
        //设置新的点集合
        customView.setmAllPointList(allPointList);
        //计算新的正方形List
        customView.setmSquarePointList(utl.countNewRectF(allPointList));
//        //设置新的最大距离集合
//        customView.setmSquarePointList(utl.getmMaxPointList());
//        customView.setmSquarePointList(utl.countMaxDistance(allPointList));
        //刷新列表
        customView.invalidate();



//        List<Point> squaleList = new ArrayList<>();
//        squaleList.add(new Point(1,3));
//        squaleList.add(new Point(1,7));
//        squaleList.add(new Point(5,7));
//        squaleList.add(new Point(5,3));
//        customView.setmSquarePointList(squaleList);


//        List<Point> allPointList = (List<Point>) intent.getSerializableExtra("pointList");
//        List<Point> mSqualeList = (List<Point>) intent.getSerializableExtra("mSqualeList");
//        customView.setmAllPointList(allPointList);
//
//        List<Point> squaleList = new ArrayList<>();
//        squaleList.add(new Point(1,3));
//        squaleList.add(new Point(1,7));
//        squaleList.add(new Point(5,7));
//        squaleList.add(new Point(5,3));
//        customView.setmSquarePointList(squaleList);
    }
}